package javagprssrv.Common;

import java.util.Calendar;
import java.util.Date;

public class DateTime
{
    public java.lang.String getDateTime(final java.lang.String DateTimeFormat) {
        java.lang.String ret = "";
        final java.util.Date _date = new java.util.Date();
        int year = 0;
        int month = 0;
        int date = 0;
        int hour = 0;
        int min = 0;
        int sec = 0;
        final java.util.Calendar C = java.util.Calendar.getInstance();
        year = C.get(1);
        month = C.get(2) + 1;
        date = C.get(5);
        hour = C.get(11);
        min = C.get(12);
        sec = C.get(13);
        final java.lang.String sYear = java.lang.Integer.valueOf(year).toString();
        java.lang.String sMonth;
        if (month > 9) {
            sMonth = java.lang.Integer.valueOf(month).toString();
        }
        else {
            sMonth = "0" + java.lang.Integer.valueOf(month).toString();
        }
        java.lang.String sDate;
        if (date > 9) {
            sDate = java.lang.Integer.valueOf(date).toString();
        }
        else {
            sDate = "0" + java.lang.Integer.valueOf(date).toString();
        }
        java.lang.String sHour;
        if (hour > 9) {
            sHour = java.lang.Integer.valueOf(hour).toString();
        }
        else {
            sHour = "0" + java.lang.Integer.valueOf(hour).toString();
        }
        java.lang.String sMin;
        if (min > 9) {
            sMin = java.lang.Integer.valueOf(min).toString();
        }
        else {
            sMin = "0" + java.lang.Integer.valueOf(min).toString();
        }
        java.lang.String sSec;
        if (sec > 9) {
            sSec = java.lang.Integer.valueOf(sec).toString();
        }
        else {
            sSec = "0" + java.lang.Integer.valueOf(sec).toString();
        }
        final int DTFLength = DateTimeFormat.length();
        final int lastSP = 0;
        final java.lang.String lastChar = "";
        int iSP = 0;
        for (int i = 0; i < DTFLength; ++i) {
            int isFormat = -1;
            final java.lang.String s = DateTimeFormat.substring(i, i + 1);
            if (s.equals("Y")) {
                for (int j = 0; j < DTFLength - i - 1; ++j) {
                    if (!DateTimeFormat.substring(i + j, i + j + 1).equals("Y")) {
                        iSP = j;
                        break;
                    }
                }
                ret += sYear.substring(4 - iSP);
                i = i + iSP - 1;
                isFormat = 1;
            }
            if (s.equals("M")) {
                for (int j = 0; j < DTFLength - i - 1; ++j) {
                    if (!DateTimeFormat.substring(i + j, i + j + 1).equals("M")) {
                        iSP = j;
                        break;
                    }
                }
                ret += sMonth.substring(2 - iSP);
                i = i + iSP - 1;
                isFormat = 1;
            }
            if (s.equals("D")) {
                for (int j = 0; j < DTFLength - i - 1; ++j) {
                    if (!DateTimeFormat.substring(i + j, i + j + 1).equals("D")) {
                        iSP = j;
                        break;
                    }
                }
                ret += sDate.substring(2 - iSP);
                i = i + iSP - 1;
                isFormat = 1;
            }
            if (s.equals("H")) {
                for (int j = 0; j < DTFLength - i - 1; ++j) {
                    if (!DateTimeFormat.substring(i + j, i + j + 1).equals("H")) {
                        iSP = j;
                        break;
                    }
                }
                ret += sHour.substring(2 - iSP);
                i = i + iSP - 1;
                isFormat = 1;
            }
            if (s.equals("N")) {
                for (int j = 0; j < DTFLength - i - 1; ++j) {
                    if (!DateTimeFormat.substring(i + j, i + j + 1).equals("N")) {
                        iSP = j;
                        break;
                    }
                }
                ret += sMin.substring(2 - iSP);
                i = i + iSP - 1;
                isFormat = 1;
            }
            if (s.equals("S")) {
                for (int j = 0; j < DTFLength - i - 1; ++j) {
                    if (!DateTimeFormat.substring(i + j, i + j + 1).equals("S")) {
                        iSP = j;
                        break;
                    }
                }
                ret += sSec.substring(2 - iSP);
                i = i + iSP - 1;
                isFormat = 1;
            }
            if (isFormat != 1) {
                ret += s;
            }
        }
        return ret;
    }
}
